from langchain.output_parsers import DatetimeOutputParser
from langchain.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI

api_key = "sk-6S0PtpNia71gjcfwSsDPsJ9mGqsVPr2XRQzAx1dHbJS7RW4t"
api_base="https://chatapi.littlewheat.com/v1"

output_parser = DatetimeOutputParser()
instruction = output_parser.get_format_instructions()
print(instruction)

template = """ 用户发起的提问:
{question}
{format_instructions}
"""

prompt = ChatPromptTemplate.from_template(template,
                                          partial_variables={"format_instructions":instruction})

print(prompt)

chat = ChatOpenAI(model="gpt-3.5-turbo",api_key=api_key ,base_url=api_base)

chain = prompt | chat | output_parser
output = chain.invoke({"question": "你好，请问你叫什么？"})
print(output)
